package com.wufun.overseas.rpc;

import android.text.TextUtils;

import com.fasterxml.jackson.databind.JavaType;
import com.wufun.baselibrary.net.HttpUtils;
import com.wufun.overseas.models.bean.CommonRequestBean;
import com.wufun.overseas.models.bean.HandShankAdBean;
import com.wufun.overseas.models.bean.ResultMainBean;
import com.wufun.overseas.utils.JsonMapper;

/**
 * Created by xiet on 2017/12/12.
 */

public class RpcClient {
    public ResultMainBean<HandShankAdBean> getHandShankAdList(CommonRequestBean requestBean) {
        String param = "";
        if (param != null)
            param = JsonMapper.toJsonString(requestBean);
        String response = HttpUtils.doPostSync(RpcConstant.rootUrl + RpcConstant.handshankAdList, param);

        ResultMainBean<HandShankAdBean> ret = new ResultMainBean<>();
        if (!TextUtils.isEmpty(response)) {
            try {
                JavaType javaType = JsonMapper.getInstance().createCollectionType(ResultMainBean.class, HandShankAdBean.class);
                ret = JsonMapper.getInstance().fromJson(response, javaType);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return ret;
    }
}
